<template>
	<view class="shop page bgff">
		<view class="rel">
			<swiper class="bgImg" circular autoplay v-if="video == '' || video == null">
				<swiper-item v-for="(item,index) in detail.cover" :key="index" @click="look">
					<image class="w-20" :src="item" mode="widthFix"></image>
				</swiper-item>
			</swiper>
			<video v-else :autoplay="isPlay" class="w-20" :src="detail.video" mode="widthFix"></video>
		</view>
		<view class="flex flexC flexB btns pb18 pt26 mx14 ">
			<image class="bgImg2" src="/static/img/bg/card.png"></image>
			<view @click="$refs.popup.open()" class="flex1 aliC">
				<image src="/static/img/icon/door.png" mode="aspectFill"></image>
				<view>开门</view>
			</view>
			<view class="flex1 aliC" @click="xufei">
				<image src="/static/img/icon/xudan.png" mode="aspectFill"></image>
				<view>续单</view>
			</view>
			<view class="flex1 aliC" @click="coupon">
				<image src="/static/img/icon/yh.png" mode="aspectFill"></image>
				<view>优惠</view>
			</view>
			<view class="flex1 aliC" @click="meituan">
				<image src="/static/img/icon/yan.png" mode="aspectFill"></image>
				<view>美团验券</view>
			</view>
			<view class="flex1 aliC" @click="dou">
				<image src="/static/img/icon/dou_icon.png" mode="aspectFill"></image>
				<view>抖音快手</view>
			</view>
		</view>
		<scroll-view scroll-y class="list bgff">

			<view class="table px10 py12 mb8 mx14">
				<view class="flex flexC flexB bold6">
					<image class="icon mr6" src="/static/img/icon/shop.png" mode="widthFix"></image>
					<text class="c00 flex1 ellipsis1">{{detail.name}}</text>
					<text v-if="isFav == 1" @click="clickFav" class="fs12 bgf6c r40 px8 py3 ml10">已收藏</text>
					<text v-else @click="clickFav" class="fs12 bgf6c r40 px8 py3 ml10">收藏</text>

				</view>
				<view class="mt12 flex flexE c00 fs14">
					<view class="flex1">
						<text class="mr12">{{detail.address}}</text>
						<text v-if="distance != ''" class="bor-stly dist r40 px8 fs12">{{distance}}</text>
					</view>
					<view class="flex flexC flexJC ml10 font-corlors fs10 bold4">
						<view class="flex1 aliC mt-2" @click="wechat">
							<image class="w36" src="/static/img/icon/wechat.png" mode="aspectFill"></image>
							<view>微信</view>
						</view>
						<view class="flex1 aliC ml18" @click="location">
							<image class="w36" src="/static/img/icon/local.png" mode="aspectFill"></image>
							<view>位置</view>
						</view>
						<view class="flex1 aliC ml18" @click="call">
							<image class="w36 " src="/static/img/icon/call.png" mode="aspectFill"></image>
							<view>电话</view>
						</view>
					</view>
				</view>
			</view>
			<view class="bgff r5 mb10 mx14 couponList shadow" v-if="tuanList.length >0">
				<view class="flex flexC flexB">
					<image class="w80" src="/static/img/bg/youhui.png" mode="widthFix"></image>
					<view class="flex flexC c33 fs12 pt8 pr10" @click="moreCoupon">
						<text>更多专享限时优惠</text>
						<text class="arrowR"></text>
					</view>
				</view>
				<scroll-view scroll-x class="p10 fs12 c00 boxS">
					<image @click="clickCharge" class="vipImg mx4" src="/static/img/bg/vip.png" mode="widthFix"></image>

					<view v-for="(item,index) in tuanList" :key="index" class="vipItem mx4 r4" @click="clickTuan(item)">
						<image class="imgbg" src="/static/img/bg/vipItem.png" mode="aspectFill"></image>
						<view class="cont flex flexC flexCol flexJC">
							<text class="c57 bold6 fs16">￥{{item.price}}</text>
							<text class="fs10">原价￥{{item.line_price}}元</text>
							<text class="fs10 cff mt5">限时特惠</text>
						</view>
						<view class="ellipsis1 pt5 aliC c33">{{item.name}}</view>
					</view>
				</scroll-view>

			</view>
			<!-- <swiper class="banner m10 r10" circular autoplay>
				<swiper-item class="r10" v-for="(item,index) in 1" :key="index" @click="clickCharge">
					<image class="w-20 r10" src="../../static/img/bg/charge_bg.png" mode="widthFix"></image>
				</swiper-item>
			</swiper> -->

			<!-- tab栏 -->
			<view v-if="tabs.length > 0" class="tabbox c99 fs17 pb12 flex flexC">
				<view v-for="(item,index) in tabs" class="item px14 aliC py6" :key="index" @click="clickTab(index)">
					
					<image class="w17" v-if="index == 0" src="/static/img/icon/fa.png" mode="aspectFit"></image>
					<image class="w17" v-else src="/static/img/icon/8.png" mode="aspectFit"></image>
					
					<text :class="tabIndex == index ? 'active' : ''">{{item.name}}</text>
					<image v-if="tabIndex == index" class="icon" src="/static/img/icon/sel.png" mode="widthFix"></image>
				</view>
			</view>
			
			<!-- 棋牌竞技 -->
			<block v-if="tabIndex == 0">
				<shop-item v-for="(item,index) in roomList" :key="index" :item="item"
					@openDetailPopup="openDetailPopup"></shop-item>
			</block>
			<!-- 台球竞技 -->
			<block v-else-if="tabIndex == 1 && detail.is_table_book_mode ==1">
				<view class="flex flexC px10 fs13 c33">
					<text class="fs16">桌台</text>
					<view class="flex1"></view>
					<text>空闲</text>
					<text class="c00c">{{free}}</text>
					<text>桌</text>
				</view>
				<ball-item :tableList="tableList" @openDetailPopup="openDetailPopup"></ball-item>
			</block>
			<block v-else-if="tabIndex == 1 && detail.is_table_book_mode ==2">
				<table-list-item @openDetailPopup="clickTableItem" v-for="(item,index) in tableList" :key="index" :item="item"></table-list-item>
			</block>

			<!-- ktv包厢 -->
			<block v-if="tabIndex == 2">
				<shop-item v-for="(item,index) in ktvRoom" :key="index" :item="item"
					@openDetailPopup="openDetailPopup"></shop-item>
			</block>

			<!-- <block v-else>
				<assistant-item v-for="(item,index) in roomList" :item="item" :key="index"></assistant-item>
			</block> -->
		</scroll-view>

		<uni-popup type="center" ref="popup">
			<open-room @open="open"></open-room>
		</uni-popup>

		<!-- 预定详情弹框 -->
		<uni-popup type="bottom" ref="detailPopup">
			<room-detail ref="roomDetail" :time="roomTime" :one="roomOne" @submit="doSubmit" @switchTab="switchTab"
				:item="room" @close="onClose" @selectTimeTab="selectTimeTab"></room-detail>
		</uni-popup>
		<!-- 续费弹框 -->
		<uni-popup type="center" ref="popupXufei">
			<xufei v-if="yu != null" :item="yu" @xufeiPay="xufeiPay" @closeYuding="closeYuding"></xufei>
		</uni-popup>

		<uni-popup type="center" ref="msgPop">
			<shop-pop v-if="notice != null" :item="notice" @closeNotice="closeNotice"></shop-pop>
		</uni-popup>

		<!-- 包厢约满提示 -->
		<uni-popup type="center" ref="fullPop">
			<room-full v-if="notice != null" :item="notice" @closeFull="closeFull"></room-full>
		</uni-popup>

		<uni-popup ref="timePop" type="bottom">
			<view class="popup-content2">

				<button v-for="item in xuList" class="popup-btn button"
					@click="clickXuOne(item)">{{item.order.room_name}}</button>

				<view class="popup-btn" @click="$refs.timePop.close()">取消</view>
			</view>

		</uni-popup>

		<uni-popup ref="chargePop" type="center">
			<view class="popup2">
				<image class="bg" src="/static/img/icon/pupop_bg.png" mode="aspectFill"></image>
				<image class="cover" src="/static/img/icon/jinbi.png" mode="widthFix"></image>
				<view class="cont aliC py10">
					<view class="title fs22 bold6">超值会员充值</view>
					<view class="sub fs18 bold6 mt5">最高可以省1000元</view>
					<scroll-view scroll-y class="list mt8 px18 boxS">
						<view v-for="(item,index) in chargeList" class="item r6 py6 mb6 fs15"
							@click="clickPopCharge(item,index)">
							充<text :class=" item.check == true ? 'bold6 px2 fs20' : 'px2 fs20'">{{item.amount}}</text>
							得<text
								:class=" item.check == true ? 'bold6 px2 fs20' : 'px2 fs20'">{{item.get_amount}}</text>
						</view>
					</scroll-view>
					<view class="btn aliC flex flexC flexJC mt10">
						<button class="r40 fs18" @click="doVipCharge">立即充值</button>
					</view>
				</view>
				<view class="aliC mt20" @click="$refs.chargePop.close()">
					<text class="close boxS r50 cff fs28">×</text>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tabs: [],
				isPlay: false,
				id: '',
				distance: '',
				detail: null,
				roomList: [],
				ktvRoom: [],
				room: null,
				roomOne: null,
				roomTwo: null,
				roomThree: null,
				roomTime: null,
				selectDate: '',
				tabType: 0, //时间段,
				yu: null,
				order_no: '',
				room_id: '',
				notice: null,
				isFav: -1,
				tabIndex: 0,
				is_table: -1,
				tableList: [],
				tuanList: [],
				isPaying: false,
				video: '',
				free: 0,
				xuList: [],
				shop_type: '棋牌',
				lat: '',
				lng: '',
				chargeList: [],
				selectChargeIndex:0,
				

			};
		},

		onShareAppMessage(res) {
			console.log(res);
			if (res.from === 'button') { // 来自页面内分享按钮
				console.log(res.target)
			}
			return {
				title: this.detail.name, //自定义分享标题
				path: '/pages/shop/detail?q=' + this.id, // '/pages/...'分享页面路径（打开分享时进入页），以/开头
			}
		},

		onShareTimeline(res) { //分享到朋友圈
			return {
				title: this.detail.name,
				path: '/pages/shop/detail?q=' + this.id, // '/pages/...'分享页面路径（打开分享时进入页），以/开头
			}
		},

		onLoad(option) {
			this.id = option.id;
			this.distance = option.distance;
			this.lng = uni.getStorageSync('lng');
			this.lat = uni.getStorageSync('lat');

			// this.$refs.chargePop.open();
			console.log('==lng==获取的经纬度===' + this.lng);
			console.log('===lat=获取的经纬度===' + this.lat);

			console.info("===option==" + JSON.stringify(option))
			var isRequestNotice = -1;

			if (option.q) {
				let scan_url = decodeURIComponent(option.q);

				console.info("===option==" + scan_url)

				var index = scan_url.lastIndexOf("\/");
				var result = scan_url.substring(index + 1, scan_url.length);
				this.id = result.split("-")[0];
				this.room_id = result.split("-")[1];
				console.info("===result==" + result)
				var token = uni.getStorageSync("token")
				if (token != "") {
					isRequestNotice = 1;
					this.xufei();
				}
			}

			if (option.scene) {
				let scan_url = option.scene;
				var index = scan_url.lastIndexOf("\/");
				var result = scan_url.substring(index + 1, scan_url.length);
				this.id = result.split("-")[0];
				this.room_id = result.split("-")[1];
				var token = uni.getStorageSync("token")
				if (token != "") {
					isRequestNotice = 1;
					this.xufei();
				}
			}

			if (isRequestNotice == -1) {
				this.getShopNotice();
			}
			
			this.getChargeList()

		},

		onShow() {
			this.getDetail();

		},
		methods: {
			
			clickPopCharge(item,index){
				
				item.check = !item.check;
				this.selectChargeIndex = index;
				for(var i=0;i<this.chargeList.length;i++){
					this.chargeList[i].check = false;
				}
				for(var i=0;i<this.chargeList.length;i++){
					if(item.id == this.chargeList[i].id){
						this.chargeList[i].check = true;
					}
				}
				this.$forceUpdate();
				console.info("===itemCheck==="+JSON.stringify(this.chargeList2));
			},
			
			doVipCharge() {
				this.$refs.chargePop.close();
				if (this.chargeList.length == 0) return;
				let param = {
					charge_id: this.chargeList[this.selectChargeIndex].id,
					orgId: 27
				};
				let that = this;
				this.$api.charge(param).then(res => {
					console.info(JSON.stringify(res));
					if (res.code == 1) {
			
						that.chargePay(res.data.payInfo)
			
					} else {
			
					}
				})
			},
			
			chargePay(payConfig) {
				let that = this;
				uni.requestPayment({
					provider: 'wxpay',
					timeStamp: payConfig.payTimeStamp,
					nonceStr: payConfig.paynonceStr,
					package: payConfig.payPackage,
					signType: payConfig.paySignType,
					paySign: payConfig.paySign,
					success: function(res) {
			
						that.getDetail();
					},
					fail: function(err) {
						uni.showToast({
							title: "取消充值",
							icon: 'none'
						});
					}
				});
			},

			getChargeList() {

				let param = {
					shop_id: this.id
				};
				let that = this;
				this.$api.getChargeInfo(param).then(res => {
					console.info(JSON.stringify(res));
					if (res.code == 1) {
						that.$refs.chargePop.open();
						that.chargeList = res.data.chargeList;
						that.chargeList.map(item => {
							item.check = false
						})
					} else {

					}
				})
			},

			moreCoupon() {
				uni.navigateTo({
					url: '../discount/couponIndex?id=' + this.id
				})
			},

			clickTab(index) {
				if (index == 2) {
					console.info("========shop_id=>>：" + this.id)
					console.info("========distance=>>：" + this.distance)
					uni.navigateToMiniProgram({
						appId: "wx86160f502fd2c58b",
						path: 'pages/shop/detail?id=' + this.id + '&distance=' + this.distance // path 路径
						// path: 'pages/home/index2?id='+this.id+'&distance='+this.distance// path 路径
					})
				} else {
					this.tabIndex = index;
				}

			},
			
			clickTuan(item) {

				uni.navigateTo({
					url: '../discount/groupBy?id=' + item.id
				})
			},

			getTable() {
				let param = {
					id: this.id,
				};
				let that = this;
				this.$api.tableList(param).then(res => {

					console.info(JSON.stringify(res));
					if (res.code == 1) {
						that.tableList = res.data.list;
						that.free = res.data.free;
					} else {

					}
				})
			},

			clickCharge() {
				console.info("====clickCharge====")
				uni.setStorageSync("shopId", this.id + "");
				uni.setStorageSync("tabIndex", 0);
				uni.switchTab({
					url: '../discount/index'
				})
			},

			clickFav() {

				let param = {
					shop_id: this.id
				}
				let that = this;
				this.$api.doShopFav(param).then(res => {

					if (res.code == 1) {
						that.isFav = res.data;
					} else {

					}

				})
			},

			closeNotice() {

				this.$refs.msgPop.close();
			},

			closeFull() {
				this.$refs.fullPop.close();
				if (this.notice.is_notice) {
					this.$refs.msgPop.open();
				}
			},

			getShopNotice() {
				let param = {
					lat: this.lat,
					lng: this.lng,
					shop_id: this.id
				}
				let that = this;
				this.$api.getNotice(param).then(res => {

					if (res.code == 1) {
						that.notice = res.data;
						if (res.data.is_room_full) {
							this.$refs.fullPop.open();
						} else if (res.data.is_notice) {
							this.$refs.msgPop.open();
						}

					} else {

					}

				})
			},

			clickCharge() {
				uni.setStorageSync("shopId", this.id + "");
				uni.setStorageSync("tabIndex", 0);

				uni.switchTab({
					url: '../discount/index'
				})
			},

			dou() {
				uni.navigateTo({
					url: '../discount/dou?id=' + this.id
				})
			},

			xufeiPay(item) {


				let param = {
					id: item.id,
					hour: item.hour
				};

				if (this.isPaying == true) return;
				this.isPaying = true;
				let that = this;
				this.$api.xufeiPay(param).then(res => {
					console.info(JSON.stringify(res));
					that.isPaying = false;
					if (res.code == 1) {
						that.closeYuding();
						that.order_no = res.data.order_no;
						if (res.data.payInfo != '') {
							that.wechatPay(res.data.payInfo)
						} else {
							uni.redirectTo({
								url: '../order/detail?order_no=' + that.order_no
							})
						}

					} else {
						uni.showToast({
							icon: 'none',
							title: res.msg
						})
					}

				})
			},

			wechatPay(payConfig) {
				let that = this;
				uni.requestPayment({
					provider: 'wxpay',
					timeStamp: payConfig.payTimeStamp,
					nonceStr: payConfig.paynonceStr,
					package: payConfig.payPackage,
					signType: payConfig.paySignType,
					paySign: payConfig.paySign,
					success: function(res) {

						uni.redirectTo({
							url: '../order/detail?order_no=' + that.order_no
						})

					},
					fail: function(err) {
						console.info(err);
						that.restore();
						uni.showToast({
							title: "取消续费",
							icon: 'none'
						});
					}
				});
			},

			restore() {
				let param = {
					order_no: this.order_no,
				};
				let that = this;
				this.$api.restore(param).then(res => {
					console.info(JSON.stringify(res));
					if (res.code == 1) {

					} else {
						uni.showToast({
							icon: "none",
							title: res.msg
						})
					}
				})
			},

			closeYuding() {
				this.$refs.popupXufei.close();
			},

			xufei() {

				let param = {};
				let that = this;
				this.$api.xu(param).then(res => {
					console.info(JSON.stringify(res));
					if (res.code == 1) {
						if (res.data.count > 1) {
							that.getXuFeiList();
						} else {
							that.yu = res.data;
							this.$refs.popupXufei.open();
						}
					} else {
						uni.showToast({
							icon: 'none',
							title: res.msg
						})
					}

				})
			},

			getXuFeiList() {

				let param = {

				};
				let that = this;
				this.$api.getXuList(param).then(res => {
					console.info(JSON.stringify(res));
					if (res.code == 1) {

						that.xuList = res.data;
						that.$refs.timePop.open();
					}

				})
			},

			open(item) {

				this.$refs.popup.close();

				let param = {
					type: item
				};
				let that = this;
				this.$api.open(param).then(res => {
					console.info(JSON.stringify(res));
					if (res.code == 1) {


					}
					uni.showToast({
						icon: 'none',
						title: res.msg
					})
				})
			},

			wechat() {
				if (this.detail.wx_code == "") {

					uni.showToast({
						title: "店长暂未设置微信",
						icon: 'none'
					})
					return;
				}
				let image = Array();
				image.push(this.detail.wx_code);
				uni.previewImage({
					urls: image
				});
			},
			
			meituan() {
				uni.setStorageSync("shopId", this.id + "");
				uni.navigateTo({
					url: '../discount/verification?shop=' + JSON.stringify(this.detail)
				})
			},
			
			coupon() {
				uni.setStorageSync("shopId", this.id + "");
				uni.setStorageSync("tabIndex", 1);

				uni.switchTab({
					url: '../discount/index'
				})
			},

			doSubmit(item) {
				this.$refs.detailPopup.close();
				uni.navigateTo({
					url: '../order/submit?item=' + JSON.stringify(item)
				})
			},

			selectTimeTab(item) {

				this.selectDate = item;
				if (this.tabType == 0) {
					this.getOne();
				}
				console.info("===selectTimeTab==" + this.selectDate);
			},

			getTime() {
				let param = {};
				let that = this;
				this.$api.roomTime(param).then(res => {

					console.info(JSON.stringify(res));
					if (res.code == 1) {
						that.roomTime = res.data;
						that.selectDate = res.data[0]['dateValue']
					} else {

					}
				})
			},

			switchTab(tabIndex) {

				this.tabType = tabIndex;
				if (tabIndex == 0) {
					this.getOne();
				} else if (tabIndex == 1) {
					this.getTwo();
				} else {
					this.getThree();
				}
				console.info("===switchTab====" + tabIndex);
			},

			getOne() {
				let param = {
					id: this.room.id,
					date: this.selectDate
				};
				let that = this;
				this.$api.roomTimeOne(param).then(res => {

					console.info(JSON.stringify(res));
					if (res.code == 1) {
						that.roomOne = res.data;
						that.$refs.roomDetail.setData(res.data);

					} else {

					}
				})
			},
			
			getTwo() {
				let param = {
					id: this.room.id
				};
				let that = this;
				this.$api.roomTimeTwo(param).then(res => {

					console.info(JSON.stringify(res));
					if (res.code == 1) {
						that.roomTwo = res.data;

					} else {

					}
				})
			},
			
			getThree() {
				let param = {
					id: this.room.id
				};
				let that = this;
				this.$api.roomTimeThree(param).then(res => {

					console.info(JSON.stringify(res));
					if (res.code == 1) {
						that.roomThree = res.data;
					} else {

					}
				})
			},

			look() {
				let image = Array();
				uni.previewImage({
					urls: this.detail.cover,
				});
			},

			location() {
				uni.openLocation({
						name: this.detail.name,
						latitude: parseFloat(this.detail.lat),
						longitude: parseFloat(this.detail.lng),
						address: this.detail.address,
						fail: function(res) {
							console.info(JSON.stringify(res))
						}
					},

				)
			},

			call() {

				uni.makePhoneCall({
					phoneNumber: this.detail.tel
				})
			},

			getDetail() {
				let param = {
					id: this.id
				};
				let that = this;
				this.$api.getShopDetail(param).then(res => {

					console.info(JSON.stringify(res));
					if (res.code == 1) {
						that.detail = res.data;
						that.isFav = res.data.isFav;
						that.is_table = res.data.is_table;
						that.tuanList = res.data.tuanList;
						that.video = res.data.video;
						that.shop_type = res.data.shop_type;
						that.tabs = res.data.tab;
						if (that.shop_type == '棋牌台球' || that.shop_type == '棋牌') {
							that.tabIndex = 0;
						} else if (that.shop_type == '台球棋牌' || that.shop_type == '台球') {
							that.tabIndex = 1;
						}
						if (res.data.tab.length < 1) {
							if (that.shop_type == '棋牌台球' || that.shop_type == '棋牌') {
								that.tabIndex = 0;
							} else if (that.shop_type == '台球棋牌' || that.shop_type == '台球') {
								that.tabIndex = 1;
							} else if (res.data.is_ktv == 1) {
								that.tabIndex = 2;
							}
						}
						// if (res.data.is_charge_tip == 1) {
						// 	that.getChargeList();
						// }
						that.getTable();
						that.getRoom();
						// that.getKtvRoom();
						that.getTime();
					} else {

					}
				})
			},

			clickXuOne(item) {
				this.$refs.timePop.close();
				let param = {
					order_no: item.order.order_no
				};
				let that = this;
				this.$api.xu(param).then(res => {
					console.info(JSON.stringify(res));
					if (res.code == 1) {
						that.yu = res.data;
						this.$refs.popupXufei.open();

					} else {
						uni.showToast({
							icon: 'none',
							title: res.msg
						})
					}

				})
			},

			getRoom() {
				let param = {
					shop_id: this.id
				};
				let that = this;
				this.$api.getRoomList(param).then(res => {

					console.info(JSON.stringify(res));
					if (res.code == 1) {
						that.roomList = res.data;
					} else {

					}
				})
			},

			getKtvRoom() {
				let param = {
					shop_id: this.id
				};
				let that = this;
				this.$api.getKtvRoom(param).then(res => {

					console.info(JSON.stringify(res));
					if (res.code == 1) {
						that.ktvRoom = res.data;
					} else {

					}
				})
			},
			
			clickTableItem(item){
				// console.info("====tableItem===="+JSON.stringify(item));
				
				// console.info("====tableItem中set的值=="+item.set.length);
				if(item.set.length < 1){
					uni.showToast({
						title: "添加套餐后才能使用",
						icon: 'none'
					})
					return;
				}
				
				if (item.status == 'free') {
				
					let date = new Date();
					let year = date.getFullYear(); //获取当前年份
					let mon = date.getMonth() + 1; //获取当前月份
					let da = date.getDate(); //获取当前日
					let h = date.getHours(); //获取小时
					let m = date.getMinutes(); //获取分钟
				
					if (mon < 10) {
						mon = "0" + mon;
					}
					if (da < 10) {
						da = "0" + da;
					}
				
					var obj = new Object();
					obj.id = item.id;
					obj.shop_id = item.shop_id;
					obj.hour = -1;
					obj.startDate = year + "-" + mon + "-" + da;
					uni.navigateTo({
						url: '../order/tableSubmit?item=' + JSON.stringify(obj)
					})
				} else {
			
				
					if (item.endTime != "") {
						var obj = new Object();
						obj.id = item.id;
						obj.shop_id = item.shop_id;
						obj.hour = -1;
						obj.startDate = item.endDate;
						obj.startTime = item.endTime;
				
						uni.navigateTo({
							url: '../order/tableSubmit?item=' + JSON.stringify(obj)
						})
					}
				}
			},

			openDetailPopup(item) {
				if (this.detail.temp_shop_id != -1) {
					console.info("====temp_shop_id===" + this.detail.temp_shop_id);
					uni.navigateToMiniProgram({
						appId: "wx763ae61820ee8dc5",
						path: 'pages/shop/detail?id=' + this.detail.temp_shop_id // path 路径

					})
					return;
				}


				if (this.detail.status == 3) {
					uni.showToast({
						title: "店铺还在筹备中,无法预定",
						icon: 'error'
					})
					return;
				}

				console.info("===free===" + item.isFree);
				this.room = item;

				if (item.isFree == true) {

					let date = new Date();
					let year = date.getFullYear(); //获取当前年份
					let mon = date.getMonth() + 1; //获取当前月份
					let da = date.getDate(); //获取当前日
					let h = date.getHours(); //获取小时
					let m = date.getMinutes(); //获取分钟

					if (mon < 10) {
						mon = "0" + mon;
					}
					if (da < 10) {
						da = "0" + da;
					}

					var obj = new Object();
					obj.id = item.id;
					obj.shop_id = item.shop_id;
					obj.hour = -1;
					obj.startDate = year + "-" + mon + "-" + da;
					uni.navigateTo({
						url: '../order/submit?item=' + JSON.stringify(obj)
					})
				} else {
					// this.getOne();
					// this.$refs.detailPopup.open();

					if (item.endTime != "") {
						var obj = new Object();
						obj.id = item.id;
						obj.shop_id = item.shop_id;
						obj.hour = -1;
						obj.startDate = item.endDate;
						obj.startTime = item.endTime;

						uni.navigateTo({
							url: '../order/submit?item=' + JSON.stringify(obj)
						})
					}
				}

				console.log(item)

			},
			
			onClose() {
				this.$refs.detailPopup.close();
			}
		}
	}
</script>

<style lang="scss" scoped>
	.shop {
		.c00c {
			color: #00CA69;
		}

		.tabbox {
			.w17 {width: 32rpx;height: 32rpx;margin-right: 6rpx;}
			.item {
				position: relative;

				.active {
					color: #282828;
					font-weight: 800;
				}
				
				&::after {
					content: '';
					width: 2rpx;
					height: 26rpx;
					background-color: #CFCFCF;
					position: absolute;
					top: calc(50% - 12rpx);
					right: 4rpx;
				}
				
				&:nth-child(2) {
					&::after {
						display: none;
					}
				}

				.icon {
					width: 38rpx;
					height: 10rpx;
					position: absolute;
					bottom: 0;
					left: calc(50% - 6rpx);
				}
			}
		}

		.btns {
			// background: linear-gradient(to bottom, #FFB92B, #F7DF73);
			position: relative;
			margin-top: -30rpx;

			.bgImg2 {
				position: absolute;
				top: 0;
				left: 0;
				width: 100%;
				height: 100%;
				z-index: 1;
			}

			>.flex1 {
				position: relative;
				z-index: 2;

				image {
					width: 60rpx;
					height: 60rpx;
				}
			}
		}

		.btnbox {}

		.tab {
			.bgf6c {
				color: #000;
			}
		}

		.popup2 {
			position: relative;

			.cover {
				width: 668rpx;
				height: 576rpx;
				position: absolute;
				top: -48rpx;
				left: calc(50% - 334rpx);
			}

			.bg {
				width: 568rpx;
				height: 680rpx;
			}

			.close {
				width: 60rpx;
				height: 62rpx;
				line-height: 44rpx;
				border: 4rpx solid #fff;
				display: inline-block;
			}

			.cont {
				width: 568rpx;
				height: 680rpx;
				position: absolute;
				top: 0;
				left: calc(50% - 284rpx);
				color: #F79509;

				.title {
					color: #232323;
				}

				.list {
					height: 400rpx;

					.item {
						width: 460rpx;
						border: 2rpx solid #FAD00D;
						background-color: #FEF0B4;
						color: #F79D09;
					}
				}

				.btn {
					button {
						background-color: #FAD00D;
						width: 340rpx;
						height: 76rpx;
						line-height: 76rpx;
						color: #232323;
					}
				}
			}
		}

		.couponList {
			.vipImg {
				width: 190rpx;
				height: 174rpx;
			}

			.w80 {
				width: 176rpx;
				height: 56rpx;
			}

			.vipItem {
				position: relative;
				top: 6rpx;
				width: 168rpx;
				height: 168rpx;
				display: inline-block;

				.imgbg {
					position: absolute;
					top: 0;
					left: calc(50% - 84rpx);
					z-index: 0;
					width: 168rpx;
					height: 122rpx;
				}

				.cont {
					height: 122rpx;
					position: relative;
					z-index: 2;
				}

				.txt {
					position: absolute;
					color: #fff;
					font-size: 22rpx;
					top: 80rpx;
					left: 0;
					width: 100%;
					z-index: 2;
					text-align: center;
				}
			}

			scroll-view {
				white-space: nowrap;
			}
		}

		.dist {
			// color: #F5C51D;
			color: #F95C28
		}

		.bor-stly {
			border: 2rpx solid #F95C28;
		}

		.banner {
			width: calc(100% - 40rpx);
			height: 100rpx;
		}

		.rel {
			position: relative;
		}

		.bgImg {
			width: 100%;
			height: 275rpx;
			background-color: #F8B62B;
			// image {height: 100% !important;}		
		}

		.tagbg {
			background: #FFDF39;
			color: #000;
		}

		.tags {
			position: absolute;
			bottom: 20rpx;
			left: 0;
		}

		.icon {
			width: 38rpx;
		}

		.w18 {
			width: 36rpx;
			height: 36rpx;
		}

		.w19 {
			width: 38rpx;
			height: 38rpx;
		}

		.w36 {
			width: 46rpx;
			height: 46rpx;
		}

		.mt-2 {
			margin-top: -4rpx;
		}
	}


	.popup-content2 {
		background: #FFFFFF;

		.popup-btn {
			width: 100%;
			height: 100rpx;
			line-height: 100rpx;
			text-align: center;
			border-bottom: 1px solid #f5f5f5;
			background: #FFFFFF;
		}

		.button {
			width: 100%;
			height: 100rpx;
			line-height: 100rpx;
			text-align: center;
			border-bottom: 1px solid #f5f5f5;
			background: #FFFFFF;
			font-size: 11pt;
		}

		button::after {
			border: none;
		}

		.pt20 {
			border-bottom: 20rpx solid #f5f5f5;
		}
	}

	.font-corlors {
		color: #F95C28
	}
</style>